package com.example.mq.rabbitmq.config;

import com.example.mq.rabbitmq.cansts.DirectExchangeEnum;
import com.example.mq.rabbitmq.cansts.DirectQueueEnum;
import com.example.mq.rabbitmq.cansts.RoutingKeyEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xyh
 * @description
 * @date 2021/3/31 15:26
 */
//@Configuration
public class RabbitMQDirectConfig {


    @Bean
    public Queue testDirectQueue(){

        return new Queue(DirectQueueEnum.TEST_DIRECT_QUEUE.toString(),true);
    }

    @Bean
    public DirectExchange testDirectExchange(){
        return new DirectExchange(DirectExchangeEnum.TEST_DIRECH_CHANGE.toString(),true,false);
    }

    @Bean
    public Binding bingdingDirectExchange(){
        return BindingBuilder.bind(testDirectQueue()).to(testDirectExchange()).with(RoutingKeyEnum.TEST);
    }

}
